#格式化

#format
year="虎"
name="小哈"
message_content="""
{0}年快乐
给{1}拜年啦！
""".format(year,name)
print(message_content)

message_content_1="""
{current_year}年快乐
给{receiver_name}拜年啦！
""".format(receiver_name=name,current_year=year)
print(message_content_1)

#f-字符串
year="虎"
name="小哈"
message_content_2=f"""
{year}年快乐\
给{name}拜年啦！
"""
print(message_content_2)

#用数字替换字符串的内容
gpa_dict={"anna":3.25,"john":3.86,"helen":2.912,"leaf":4.134}
for name,gpa in gpa_dict.items():
    print("{0}你好，你当前的绩点是：{1}".format(name,gpa))
print('\n')


for name,gpa in gpa_dict.items():
    print("{0}你好，你当前的绩点是：{1:.2f}".format(name,gpa))
  # [:.数字f ]可用来指定数字在格式化时保留几位小数
print('\n')

for name,gpa in gpa_dict.items():
    print(f"{name}你好，你当前的绩点是：{gpa:.2f}")